package com.thalesgroup.preferenceFramework.models.LCPnet.impl;

import junit.framework.TestCase;

import org.eclipse.emf.common.util.EList;
import org.junit.Test;

import com.thalesgroup.preferenceFramework.models.Outcome;
import com.thalesgroup.preferenceFramework.models.LCPnet.COutcome;
import com.thalesgroup.preferenceFramework.models.LCPnet.LCPnet;
import com.thalesgroup.preferenceFramework.models.LCPnet.exceptions.LCPnetEvaluationException;

public class COutcomeImplTests extends TestCase {

	@Test
	public void testGetUtility() throws LCPnetEvaluationException {
		LCPnet net = LCPnetImpl
				.load("tests/com/thalesgroup/preferenceFramework/models/LCPnet/impl/coutcome_test_selector_set.lcpnet");
		assertNotNull(net);
		EList<Outcome> outcomes = net.getOutcomes();
		for (Outcome outcome : outcomes) {
			if (outcome instanceof COutcome) {
				COutcome coutcome = (COutcome) outcome;
				assertEquals(coutcome.getUtility(), 0.7796301447227277);
				return;
			}
		}
		fail("No outcome found in test LCPNet");
	}

	@Test
	public void testGetUtility2() throws LCPnetEvaluationException {
		LCPnet net = LCPnetImpl
				.load("tests/com/thalesgroup/preferenceFramework/models/LCPnet/impl/lcpnet_test.lcpnet");
		assertNotNull(net);

		EList<Outcome> outcomes = net.getOutcomes();
		for (Outcome outcome : outcomes) {
			if (outcome instanceof COutcome) {
				COutcome coutcome = (COutcome) outcome;
				assertEquals(coutcome.getUtility(), 0.7072621253417823);
				return;
			}
		}

		fail("No outcome found in test LCPNet");
	}
}
